package com.tjsinfo.tjsoa.vote.bo;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.tjsinfo.tjsoa.Dao.IQbcDao;
import com.tjsinfo.tjsoa.vote.dao.ITVoteConformationDAO;
import com.tjsinfo.tjsoa.vote.vo.TVoteConformation;

public class TVoteConformationBO implements ITVoteConformationBO {
	
	private IQbcDao qbcDao;	
	private ITVoteConformationDAO conformationDao;
	
	public IQbcDao getQbcDao() {
		return qbcDao;
	}
	public void setQbcDao(IQbcDao qbcDao) {
		this.qbcDao = qbcDao;
	}
	public ITVoteConformationDAO getConformationDao() {
		return conformationDao;
	}
	public void setConformationDao(ITVoteConformationDAO conformationDao) {
		this.conformationDao = conformationDao;
	}
	
	public void save(TVoteConformation transientInstance) {
		// TODO Auto-generated method stub
		conformationDao.save(transientInstance);
	}
	
	public List findRowStatus(String status, String headId){
		DetachedCriteria criteria = DetachedCriteria.forClass(TVoteConformation.class);
		criteria.add(Restrictions.eq("headId", headId));
		criteria.add(Restrictions.eq(status, 0));
		criteria.add(Restrictions.eq("parentId", null));
		List list = qbcDao.getCriteria(criteria);
		return list;
	}

	public List findBy(String headId){
		DetachedCriteria criteria = DetachedCriteria.forClass(TVoteConformation.class);
		criteria.add(Restrictions.eq("headId", headId));
		criteria.add(Restrictions.eq("parentId", "0"));
		List list = qbcDao.getCriteria(criteria);
		return list;
	}	
	
	public List find(String headId){
		DetachedCriteria criteria = DetachedCriteria.forClass(TVoteConformation.class);
		criteria.add(Restrictions.eq("headId", headId));
		criteria.add(Restrictions.not(Restrictions.eq("parentId", "0")));
		List list = qbcDao.getCriteria(criteria);
		return list;
	}
	public TVoteConformation findById(String id) {
		// TODO Auto-generated method stub
		return conformationDao.findById(id);
	}
	public void delete(String id) {
		// TODO Auto-generated method stub
		conformationDao.delete(id);
	}
	public void update(TVoteConformation transientInstance) {
		// TODO Auto-generated method stub
		conformationDao.update(transientInstance);
	}
	public void deleteC(String headId, String parentId) {
		// TODO Auto-generated method stub
		conformationDao.deleteC(headId, parentId);
	}
	public void deleteA(String headId) {
		// TODO Auto-generated method stub
		conformationDao.deleteA(headId);
	}	

}
